package com.tjzd.learn2;

//定义一个方法，把一个数组中的fo到to的值拷贝到另一个数组中去
public class copyarr {
    public static void main(String[] args) {
        int array[]={3,4,5,6,7,8};
        int x[]=copyarray(array,1,3);
        for (int i = 0; i < x.length; i++) {
            System.out.print(x[i]+" ");

        }
    }
    public static int[] copyarray(int arr[],int fo,int to){
        int arr1[]=new int[to-fo];
        int n=0;
        //fo不能>=to
        for (int i =fo;i<to;i++) {
            arr1[n]=arr[i];
            n++;
        }
        return arr1;
    }
}
